package com.weilx959.spt.core.exception;

import com.weilx959.spt.core.component.FormItemControl;

import java.io.Serial;

/**
 * 表单控件异常
 *
 * @author weilx
 * @since 2024-08-01
 */
@SuppressWarnings("rawtypes")
public class FormControlException extends RuntimeException {
    @Serial
    private static final long serialVersionUID = 2059708897560664073L;

    /**
     * 表单控件类
     */
    private final Class<? extends FormItemControl> controlClass;

    public FormControlException(Throwable cause, Class<? extends FormItemControl> controlClass) {
        super(cause);
        this.controlClass = controlClass;
    }

    public FormControlException(String message, Class<? extends FormItemControl> controlClass) {
        super(message);
        this.controlClass = controlClass;
    }

    public FormControlException(String message, Throwable cause, Class<? extends FormItemControl> controlClass) {
        super(message, cause);
        this.controlClass = controlClass;
    }

    @Override
    public String getMessage() {
        return "form control(" + controlClass.getName() + ") error with message: " + super.getMessage();
    }
}
